/*     */ package org.yaml.snakeyamla.configuration;
/*     */ 
/*     */ import java.util.ArrayList;
/*     */ import java.util.LinkedHashMap;
/*     */ import java.util.LinkedHashSet;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.Set;
/*     */ import net.minecraft.item.ItemStack;
/*     */ import net.minecraft.nbt.JsonToNBT;
/*     */ import net.minecraft.nbt.NBTException;
/*     */ import net.minecraft.nbt.NBTTagCompound;
/*     */ import org.apache.commons.lang3.Validate;
/*     */ import org.yaml.snakeyamla.configuration.file.YamlConfiguration;
/*     */ 
/*     */ public class MemorySection
/*     */   implements ConfigurationSection {
/*  18 */   protected final Map<String, Object> map = new LinkedHashMap<>();
/*     */   private final Configuration root;
/*     */   private final ConfigurationSection parent;
/*     */   private final String path;
/*     */   private final String fullPath;
/*     */   private String fileName;
/*     */   
/*     */   public void setFileName(String fileName) {
/*  26 */     this.fileName = fileName;
/*     */   }
/*     */   
/*     */   public String getFileName() {
/*  30 */     return this.fileName;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   protected MemorySection() {
/*  44 */     if (!(this instanceof Configuration)) {
/*  45 */       throw new IllegalStateException("Cannot construct a root MemorySection when not a Configuration");
/*     */     }
/*     */     
/*  48 */     this.path = "";
/*  49 */     this.fullPath = "";
/*  50 */     this.parent = null;
/*  51 */     this.root = (Configuration)this;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   protected MemorySection(ConfigurationSection parent, String path) {
/*  64 */     Validate.notNull(parent, "Parent cannot be null", new Object[0]);
/*  65 */     Validate.notNull(path, "Path cannot be null", new Object[0]);
/*     */     
/*  67 */     this.path = path;
/*  68 */     this.parent = parent;
/*  69 */     this.root = parent.getRoot();
/*     */     
/*  71 */     Validate.notNull(this.root, "Path cannot be orphaned", new Object[0]);
/*     */     
/*  73 */     this.fullPath = createPath(parent, path);
/*     */   }
/*     */   
/*     */   public Set<String> getKeys(boolean deep) {
/*  77 */     Set<String> result = new LinkedHashSet<>();
/*     */     
/*  79 */     Configuration root = getRoot();
/*  80 */     if (root != null && root.options().copyDefaults()) {
/*  81 */       ConfigurationSection defaults = getDefaultSection();
/*     */       
/*  83 */       if (defaults != null) {
/*  84 */         result.addAll(defaults.getKeys(deep));
/*     */       }
/*     */     } 
/*     */     
/*  88 */     mapChildrenKeys(result, this, deep);
/*     */     
/*  90 */     return result;
/*     */   }
/*     */   
/*     */   public List<ConfigurationSection> getSections() {
/*  94 */     List<ConfigurationSection> list = new ArrayList<>();
/*  95 */     for (String key : getKeys(false)) {
/*  96 */       ConfigurationSection section = getConfigurationSection(key);
/*  97 */       if (section != null) {
/*  98 */         list.add(section);
/*     */       }
/*     */     } 
/* 101 */     return list;
/*     */   }
/*     */   
/*     */   public Map<String, Object> getValues(boolean deep) {
/* 105 */     Map<String, Object> result = new LinkedHashMap<>();
/*     */     
/* 107 */     Configuration root = getRoot();
/* 108 */     if (root != null && root.options().copyDefaults()) {
/* 109 */       ConfigurationSection defaults = getDefaultSection();
/*     */       
/* 111 */       if (defaults != null) {
/* 112 */         result.putAll(defaults.getValues(deep));
/*     */       }
/*     */     } 
/*     */     
/* 116 */     mapChildrenValues(result, this, deep);
/*     */     
/* 118 */     return result;
/*     */   }
/*     */   
/*     */   public boolean contains(String path) {
/* 122 */     return (get(path) != null);
/*     */   }
/*     */   
/*     */   public boolean isSet(String path) {
/* 126 */     Configuration root = getRoot();
/* 127 */     if (root == null) {
/* 128 */       return false;
/*     */     }
/* 130 */     if (root.options().copyDefaults()) {
/* 131 */       return contains(path);
/*     */     }
/* 133 */     return (get(path, null) != null);
/*     */   }
/*     */   
/*     */   public String getCurrentPath() {
/* 137 */     return this.fullPath;
/*     */   }
/*     */   
/*     */   public String getName() {
/* 141 */     return this.path;
/*     */   }
/*     */   
/*     */   public Configuration getRoot() {
/* 145 */     return this.root;
/*     */   }
/*     */   
/*     */   public ConfigurationSection getParent() {
/* 149 */     return this.parent;
/*     */   }
/*     */   
/*     */   public void addDefault(String path, Object value) {
/* 153 */     Validate.notNull(path, "Path cannot be null", new Object[0]);
/*     */     
/* 155 */     Configuration root = getRoot();
/* 156 */     if (root == null) {
/* 157 */       throw new IllegalStateException("Cannot add default without root");
/*     */     }
/* 159 */     if (root == this) {
/* 160 */       throw new UnsupportedOperationException("Unsupported addDefault(String, Object) implementation");
/*     */     }
/* 162 */     root.addDefault(createPath(this, path), value);
/*     */   }
/*     */   
/*     */   public ConfigurationSection getDefaultSection() {
/* 166 */     Configuration root = getRoot();
/* 167 */     Configuration defaults = (root == null) ? null : root.getDefaults();
/*     */     
/* 169 */     if (defaults != null && 
/* 170 */       defaults.isConfigurationSection(getCurrentPath())) {
/* 171 */       return defaults.getConfigurationSection(getCurrentPath());
/*     */     }
/*     */ 
/*     */     
/* 175 */     return null;
/*     */   }
/*     */   
/*     */   public void set(String path, Object value) {
/* 179 */     Validate.notEmpty(path, "Cannot set to an empty path", new Object[0]);
/*     */     
/* 181 */     Configuration root = getRoot();
/* 182 */     if (root == null) {
/* 183 */       throw new IllegalStateException("Cannot use section without a root");
/*     */     }
/*     */     
/* 186 */     char separator = root.options().pathSeparator();
/*     */ 
/*     */     
/* 189 */     int i1 = -1;
/* 190 */     ConfigurationSection section = this; int i2;
/* 191 */     while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
/* 192 */       String node = path.substring(i2, i1);
/* 193 */       ConfigurationSection subSection = section.getConfigurationSection(node);
/* 194 */       if (subSection == null) {
/* 195 */         section = section.createSection(node); continue;
/*     */       } 
/* 197 */       section = subSection;
/*     */     } 
/*     */ 
/*     */     
/* 201 */     String key = path.substring(i2);
/* 202 */     if (section == this) {
/* 203 */       if (value == null) {
/* 204 */         this.map.remove(key);
/*     */       } else {
/* 206 */         this.map.put(key, value);
/*     */       } 
/*     */     } else {
/* 209 */       section.set(key, value);
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public void setBefore(String path, String before, Object value) {
/* 216 */     Validate.notEmpty(path, "Cannot set to an empty path", new Object[0]);
/*     */     
/* 218 */     Configuration root = getRoot();
/* 219 */     if (root == null) {
/* 220 */       throw new IllegalStateException("Cannot use section without a root");
/*     */     }
/*     */     
/* 223 */     char separator = root.options().pathSeparator();
/*     */ 
/*     */     
/* 226 */     int i1 = -1;
/* 227 */     ConfigurationSection section = this; int i2;
/* 228 */     while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
/* 229 */       String node = path.substring(i2, i1);
/* 230 */       ConfigurationSection subSection = section.getConfigurationSection(node);
/* 231 */       if (subSection == null) {
/* 232 */         section = section.createSection(node); continue;
/*     */       } 
/* 234 */       section = subSection;
/*     */     } 
/*     */ 
/*     */     
/* 238 */     String key = path.substring(i2);
/* 239 */     if (section == this) {
/* 240 */       if (value == null) {
/* 241 */         this.map.remove(key);
/*     */       } else {
/* 243 */         Map<String, Object> map = new LinkedHashMap<>();
/* 244 */         for (Map.Entry<String, Object> entry : this.map.entrySet()) {
/* 245 */           if (((String)entry.getKey()).equals(before)) {
/* 246 */             map.put(key, value);
/*     */           }
/* 248 */           map.put(entry.getKey(), entry.getValue());
/*     */         } 
/* 250 */         this.map.clear();
/* 251 */         this.map.putAll(map);
/*     */       } 
/*     */     } else {
/* 254 */       section.set(key, value);
/*     */     } 
/*     */   }
/*     */   
/*     */   public Object get(String path) {
/* 259 */     return get(path, getDefault(path));
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public Object get(String path, Object def) {
/* 276 */     Validate.notNull(path, "Path cannot be null", new Object[0]);
/*     */     
/* 278 */     if (path.length() == 0) {
/* 279 */       return this;
/*     */     }
/*     */     
/* 282 */     Configuration root = getRoot();
/* 283 */     if (root == null) {
/* 284 */       throw new IllegalStateException("Cannot access section without a root");
/*     */     }
/*     */     
/* 287 */     char separator = root.options().pathSeparator();
/*     */ 
/*     */     
/* 290 */     int i1 = -1;
/* 291 */     ConfigurationSection section = this; int i2;
/* 292 */     while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
/* 293 */       section = section.getConfigurationSection(path.substring(i2, i1));
/* 294 */       if (section == null) {
/* 295 */         return def;
/*     */       }
/*     */     } 
/*     */     
/* 299 */     String key = path.substring(i2);
/* 300 */     if (section == this) {
/* 301 */       Object result = this.map.get(key);
/* 302 */       return (result == null) ? def : result;
/*     */     } 
/* 304 */     return section.get(key, def);
/*     */   }
/*     */   
/*     */   public ConfigurationSection createSection(String path) {
/* 308 */     Validate.notEmpty(path, "Cannot create section at empty path", new Object[0]);
/* 309 */     Configuration root = getRoot();
/* 310 */     if (root == null) {
/* 311 */       throw new IllegalStateException("Cannot create section without a root");
/*     */     }
/*     */     
/* 314 */     char separator = root.options().pathSeparator();
/*     */ 
/*     */     
/* 317 */     int i1 = -1;
/* 318 */     ConfigurationSection section = this; int i2;
/* 319 */     while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
/* 320 */       String node = path.substring(i2, i1);
/* 321 */       ConfigurationSection subSection = section.getConfigurationSection(node);
/* 322 */       if (subSection == null) {
/* 323 */         section = section.createSection(node); continue;
/*     */       } 
/* 325 */       section = subSection;
/*     */     } 
/*     */ 
/*     */     
/* 329 */     String key = path.substring(i2);
/* 330 */     if (section == this) {
/* 331 */       ConfigurationSection result = new MemorySection(this, key);
/* 332 */       this.map.put(key, result);
/* 333 */       return result;
/*     */     } 
/* 335 */     return section.createSection(key);
/*     */   }
/*     */   
/*     */   public ConfigurationSection createSection(String path, Map<?, ?> map) {
/* 339 */     ConfigurationSection section = createSection(path);
/*     */     
/* 341 */     for (Map.Entry<?, ?> entry : map.entrySet()) {
/* 342 */       if (entry.getValue() instanceof Map) {
/* 343 */         section.createSection(entry.getKey().toString(), (Map<?, ?>)entry.getValue()); continue;
/*     */       } 
/* 345 */       section.set(entry.getKey().toString(), entry.getValue());
/*     */     } 
/*     */ 
/*     */     
/* 349 */     return section;
/*     */   }
/*     */ 
/*     */   
/*     */   public String getString(String path) {
/* 354 */     Object def = getDefault(path);
/* 355 */     return getString(path, (def != null) ? def.toString() : null);
/*     */   }
/*     */   
/*     */   public String getString(String path, String def) {
/* 359 */     Object val = get(path, def);
/* 360 */     String back = (val != null) ? val.toString() : def;
/*     */ 
/*     */ 
/*     */     
/* 364 */     return back;
/*     */   }
/*     */   
/*     */   public boolean isString(String path) {
/* 368 */     Object val = get(path);
/* 369 */     return val instanceof String;
/*     */   }
/*     */   
/*     */   public int getInt(String path) {
/* 373 */     Object def = getDefault(path);
/* 374 */     return getInt(path, (def instanceof Number) ? toInt(def) : 0);
/*     */   }
/*     */   
/*     */   public int getInt(String path, int def) {
/* 378 */     Object val = get(path, Integer.valueOf(def));
/* 379 */     return (val instanceof Number) ? toInt(val) : def;
/*     */   }
/*     */   
/*     */   public boolean isInt(String path) {
/* 383 */     Object val = get(path);
/* 384 */     return val instanceof Integer;
/*     */   }
/*     */   
/*     */   public boolean getBoolean(String path) {
/* 388 */     Object def = getDefault(path);
/* 389 */     return getBoolean(path, (def instanceof Boolean) ? ((Boolean)def).booleanValue() : false);
/*     */   }
/*     */   
/*     */   public boolean getBoolean(String path, boolean def) {
/* 393 */     Object val = get(path, Boolean.valueOf(def));
/* 394 */     return (val instanceof Boolean) ? ((Boolean)val).booleanValue() : def;
/*     */   }
/*     */   
/*     */   public boolean isBoolean(String path) {
/* 398 */     Object val = get(path);
/* 399 */     return val instanceof Boolean;
/*     */   }
/*     */   
/*     */   public double getDouble(String path) {
/* 403 */     Object def = getDefault(path);
/* 404 */     return getDouble(path, (def instanceof Number) ? toDouble(def) : 0.0D);
/*     */   }
/*     */   
/*     */   public double getDouble(String path, double def) {
/* 408 */     Object val = get(path, Double.valueOf(def));
/* 409 */     return (val instanceof Number) ? toDouble(val) : def;
/*     */   }
/*     */   
/*     */   public boolean isDouble(String path) {
/* 413 */     Object val = get(path);
/* 414 */     return val instanceof Double;
/*     */   }
/*     */   
/*     */   public long getLong(String path) {
/* 418 */     Object def = getDefault(path);
/* 419 */     return getLong(path, (def instanceof Number) ? toLong(def) : 0L);
/*     */   }
/*     */   
/*     */   public long getLong(String path, long def) {
/* 423 */     Object val = get(path, Long.valueOf(def));
/* 424 */     return (val instanceof Number) ? toLong(val) : def;
/*     */   }
/*     */   
/*     */   public boolean isLong(String path) {
/* 428 */     Object val = get(path);
/* 429 */     return val instanceof Long;
/*     */   }
/*     */ 
/*     */   
/*     */   public List<?> getList(String path) {
/* 434 */     Object def = getDefault(path);
/* 435 */     return getList(path, (def instanceof List) ? (List)def : null);
/*     */   }
/*     */   
/*     */   public List<?> getList(String path, List<?> def) {
/* 439 */     Object val = get(path, def);
/* 440 */     return (val instanceof List) ? (List)val : def;
/*     */   }
/*     */   
/*     */   public boolean isList(String path) {
/* 444 */     Object val = get(path);
/* 445 */     return val instanceof List;
/*     */   }
/*     */   
/*     */   public List<String> getStringList(String path) {
/* 449 */     List<?> list = getList(path);
/*     */     
/* 451 */     if (list == null) {
/* 452 */       return new ArrayList<>(0);
/*     */     }
/*     */     
/* 455 */     List<String> result = new ArrayList<>();
/*     */     
/* 457 */     for (Object object : list) {
/* 458 */       if (object instanceof String || isPrimitiveWrapper(object)) {
/* 459 */         result.add(String.valueOf(object));
/*     */       }
/*     */     } 
/*     */     
/* 463 */     return result;
/*     */   }
/*     */   
/*     */   public ItemStack getItemStack(String path, ItemStack def) {
/* 467 */     String string = getString(path);
/* 468 */     if (string == null) {
/* 469 */       return def;
/*     */     }
/*     */     try {
/* 472 */       NBTTagCompound nbtbase = JsonToNBT.func_180713_a(string);
/* 473 */       return new ItemStack(nbtbase);
/* 474 */     } catch (NBTException e) {
/* 475 */       return def;
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public List<Integer> getIntegerList(String path) {
/* 482 */     List<?> list = getList(path);
/*     */     
/* 484 */     if (list == null) {
/* 485 */       return new ArrayList<>(0);
/*     */     }
/*     */     
/* 488 */     List<Integer> result = new ArrayList<>();
/*     */     
/* 490 */     for (Object object : list) {
/* 491 */       if (object instanceof Integer) {
/* 492 */         result.add((Integer)object); continue;
/* 493 */       }  if (object instanceof String) {
/*     */         try {
/* 495 */           result.add(Integer.valueOf((String)object));
/* 496 */         } catch (Exception exception) {} continue;
/*     */       } 
/* 498 */       if (object instanceof Character) {
/* 499 */         result.add(Integer.valueOf(((Character)object).charValue())); continue;
/* 500 */       }  if (object instanceof Number) {
/* 501 */         result.add(Integer.valueOf(((Number)object).intValue()));
/*     */       }
/*     */     } 
/*     */     
/* 505 */     return result;
/*     */   }
/*     */   
/*     */   public List<Boolean> getBooleanList(String path) {
/* 509 */     List<?> list = getList(path);
/*     */     
/* 511 */     if (list == null) {
/* 512 */       return new ArrayList<>(0);
/*     */     }
/*     */     
/* 515 */     List<Boolean> result = new ArrayList<>();
/*     */     
/* 517 */     for (Object object : list) {
/* 518 */       if (object instanceof Boolean) {
/* 519 */         result.add((Boolean)object); continue;
/* 520 */       }  if (object instanceof String) {
/* 521 */         if (Boolean.TRUE.toString().equals(object)) {
/* 522 */           result.add(Boolean.valueOf(true)); continue;
/* 523 */         }  if (Boolean.FALSE.toString().equals(object)) {
/* 524 */           result.add(Boolean.valueOf(false));
/*     */         }
/*     */       } 
/*     */     } 
/*     */     
/* 529 */     return result;
/*     */   }
/*     */   
/*     */   public List<Double> getDoubleList(String path) {
/* 533 */     List<?> list = getList(path);
/*     */     
/* 535 */     if (list == null) {
/* 536 */       return new ArrayList<>(0);
/*     */     }
/*     */     
/* 539 */     List<Double> result = new ArrayList<>();
/*     */     
/* 541 */     for (Object object : list) {
/* 542 */       if (object instanceof Double) {
/* 543 */         result.add((Double)object); continue;
/* 544 */       }  if (object instanceof String) {
/*     */         try {
/* 546 */           result.add(Double.valueOf((String)object));
/* 547 */         } catch (Exception exception) {} continue;
/*     */       } 
/* 549 */       if (object instanceof Character) {
/* 550 */         result.add(Double.valueOf(((Character)object).charValue())); continue;
/* 551 */       }  if (object instanceof Number) {
/* 552 */         result.add(Double.valueOf(((Number)object).doubleValue()));
/*     */       }
/*     */     } 
/*     */     
/* 556 */     return result;
/*     */   }
/*     */   
/*     */   public List<Float> getFloatList(String path) {
/* 560 */     List<?> list = getList(path);
/*     */     
/* 562 */     if (list == null) {
/* 563 */       return new ArrayList<>(0);
/*     */     }
/*     */     
/* 566 */     List<Float> result = new ArrayList<>();
/*     */     
/* 568 */     for (Object object : list) {
/* 569 */       if (object instanceof Float) {
/* 570 */         result.add((Float)object); continue;
/* 571 */       }  if (object instanceof String) {
/*     */         try {
/* 573 */           result.add(Float.valueOf((String)object));
/* 574 */         } catch (Exception exception) {} continue;
/*     */       } 
/* 576 */       if (object instanceof Character) {
/* 577 */         result.add(Float.valueOf(((Character)object).charValue())); continue;
/* 578 */       }  if (object instanceof Number) {
/* 579 */         result.add(Float.valueOf(((Number)object).floatValue()));
/*     */       }
/*     */     } 
/*     */     
/* 583 */     return result;
/*     */   }
/*     */   
/*     */   public List<Long> getLongList(String path) {
/* 587 */     List<?> list = getList(path);
/*     */     
/* 589 */     if (list == null) {
/* 590 */       return new ArrayList<>(0);
/*     */     }
/*     */     
/* 593 */     List<Long> result = new ArrayList<>();
/*     */     
/* 595 */     for (Object object : list) {
/* 596 */       if (object instanceof Long) {
/* 597 */         result.add((Long)object); continue;
/* 598 */       }  if (object instanceof String) {
/*     */         try {
/* 600 */           result.add(Long.valueOf((String)object));
/* 601 */         } catch (Exception exception) {} continue;
/*     */       } 
/* 603 */       if (object instanceof Character) {
/* 604 */         result.add(Long.valueOf(((Character)object).charValue())); continue;
/* 605 */       }  if (object instanceof Number) {
/* 606 */         result.add(Long.valueOf(((Number)object).longValue()));
/*     */       }
/*     */     } 
/*     */     
/* 610 */     return result;
/*     */   }
/*     */   
/*     */   public List<Byte> getByteList(String path) {
/* 614 */     List<?> list = getList(path);
/*     */     
/* 616 */     if (list == null) {
/* 617 */       return new ArrayList<>(0);
/*     */     }
/*     */     
/* 620 */     List<Byte> result = new ArrayList<>();
/*     */     
/* 622 */     for (Object object : list) {
/* 623 */       if (object instanceof Byte) {
/* 624 */         result.add((Byte)object); continue;
/* 625 */       }  if (object instanceof String) {
/*     */         try {
/* 627 */           result.add(Byte.valueOf((String)object));
/* 628 */         } catch (Exception exception) {} continue;
/*     */       } 
/* 630 */       if (object instanceof Character) {
/* 631 */         result.add(Byte.valueOf((byte)((Character)object).charValue())); continue;
/* 632 */       }  if (object instanceof Number) {
/* 633 */         result.add(Byte.valueOf(((Number)object).byteValue()));
/*     */       }
/*     */     } 
/*     */     
/* 637 */     return result;
/*     */   }
/*     */   
/*     */   public List<Character> getCharacterList(String path) {
/* 641 */     List<?> list = getList(path);
/*     */     
/* 643 */     if (list == null) {
/* 644 */       return new ArrayList<>(0);
/*     */     }
/*     */     
/* 647 */     List<Character> result = new ArrayList<>();
/*     */     
/* 649 */     for (Object object : list) {
/* 650 */       if (object instanceof Character) {
/* 651 */         result.add((Character)object); continue;
/* 652 */       }  if (object instanceof String) {
/* 653 */         String str = (String)object;
/*     */         
/* 655 */         if (str.length() == 1)
/* 656 */           result.add(Character.valueOf(str.charAt(0)));  continue;
/*     */       } 
/* 658 */       if (object instanceof Number) {
/* 659 */         result.add(Character.valueOf((char)((Number)object).intValue()));
/*     */       }
/*     */     } 
/*     */     
/* 663 */     return result;
/*     */   }
/*     */   
/*     */   public List<Short> getShortList(String path) {
/* 667 */     List<?> list = getList(path);
/*     */     
/* 669 */     if (list == null) {
/* 670 */       return new ArrayList<>(0);
/*     */     }
/*     */     
/* 673 */     List<Short> result = new ArrayList<>();
/*     */     
/* 675 */     for (Object object : list) {
/* 676 */       if (object instanceof Short) {
/* 677 */         result.add((Short)object); continue;
/* 678 */       }  if (object instanceof String) {
/*     */         try {
/* 680 */           result.add(Short.valueOf((String)object));
/* 681 */         } catch (Exception exception) {} continue;
/*     */       } 
/* 683 */       if (object instanceof Character) {
/* 684 */         result.add(Short.valueOf((short)((Character)object).charValue())); continue;
/* 685 */       }  if (object instanceof Number) {
/* 686 */         result.add(Short.valueOf(((Number)object).shortValue()));
/*     */       }
/*     */     } 
/*     */     
/* 690 */     return result;
/*     */   }
/*     */   
/*     */   public List<Map<?, ?>> getMapList(String path) {
/* 694 */     List<?> list = getList(path);
/* 695 */     List<Map<?, ?>> result = new ArrayList<>();
/*     */     
/* 697 */     if (list == null) {
/* 698 */       return result;
/*     */     }
/*     */     
/* 701 */     for (Object object : list) {
/* 702 */       if (object instanceof Map) {
/* 703 */         result.add((Map<?, ?>)object);
/*     */       }
/*     */     } 
/*     */     
/* 707 */     return result;
/*     */   }
/*     */ 
/*     */   
/*     */   public boolean isColor(String path) {
/* 712 */     return false;
/*     */   }
/*     */ 
/*     */   
/*     */   public ConfigurationSection getConfigurationSection(String path) {
/* 717 */     Object val = get(path, null);
/* 718 */     if (val != null) {
/* 719 */       return (val instanceof ConfigurationSection) ? (ConfigurationSection)val : null;
/*     */     }
/*     */     
/* 722 */     val = get(path, getDefault(path));
/* 723 */     return (val instanceof ConfigurationSection) ? createSection(path) : null;
/*     */   }
/*     */   
/*     */   public ConfigurationSection getConfigurationSectionNonNull(String path) {
/* 727 */     Object val = get(path, null);
/* 728 */     if (val != null) {
/* 729 */       return (val instanceof ConfigurationSection) ? (ConfigurationSection)val : (ConfigurationSection)new YamlConfiguration();
/*     */     }
/*     */     
/* 732 */     val = get(path, getDefault(path));
/* 733 */     return (val instanceof ConfigurationSection) ? createSection(path) : (ConfigurationSection)new YamlConfiguration();
/*     */   }
/*     */   
/*     */   public boolean isConfigurationSection(String path) {
/* 737 */     Object val = get(path);
/* 738 */     return val instanceof ConfigurationSection;
/*     */   }
/*     */   
/*     */   protected boolean isPrimitiveWrapper(Object input) {
/* 742 */     return (input instanceof Integer || input instanceof Boolean || input instanceof Character || input instanceof Byte || input instanceof Short || input instanceof Double || input instanceof Long || input instanceof Float);
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   protected Object getDefault(String path) {
/* 749 */     Validate.notNull(path, "Path cannot be null", new Object[0]);
/*     */     
/* 751 */     Configuration root = getRoot();
/* 752 */     Configuration defaults = (root == null) ? null : root.getDefaults();
/* 753 */     return (defaults == null) ? null : defaults.get(createPath(this, path));
/*     */   }
/*     */   
/*     */   protected void mapChildrenKeys(Set<String> output, ConfigurationSection section, boolean deep) {
/* 757 */     if (section instanceof MemorySection) {
/* 758 */       MemorySection sec = (MemorySection)section;
/*     */       
/* 760 */       for (Map.Entry<String, Object> entry : sec.map.entrySet()) {
/* 761 */         output.add(createPath(section, entry.getKey(), this));
/*     */         
/* 763 */         if (deep && entry.getValue() instanceof ConfigurationSection) {
/* 764 */           ConfigurationSection subsection = (ConfigurationSection)entry.getValue();
/* 765 */           mapChildrenKeys(output, subsection, deep);
/*     */         } 
/*     */       } 
/*     */     } else {
/* 769 */       Set<String> keys = section.getKeys(deep);
/*     */       
/* 771 */       for (String key : keys) {
/* 772 */         output.add(createPath(section, key, this));
/*     */       }
/*     */     } 
/*     */   }
/*     */   
/*     */   protected void mapChildrenValues(Map<String, Object> output, ConfigurationSection section, boolean deep) {
/* 778 */     if (section instanceof MemorySection) {
/* 779 */       MemorySection sec = (MemorySection)section;
/*     */       
/* 781 */       for (Map.Entry<String, Object> entry : sec.map.entrySet()) {
/* 782 */         output.put(createPath(section, entry.getKey(), this), entry.getValue());
/*     */         
/* 784 */         if (entry.getValue() instanceof ConfigurationSection && 
/* 785 */           deep) {
/* 786 */           mapChildrenValues(output, (ConfigurationSection)entry.getValue(), deep);
/*     */         }
/*     */       } 
/*     */     } else {
/*     */       
/* 791 */       Map<String, Object> values = section.getValues(deep);
/*     */       
/* 793 */       for (Map.Entry<String, Object> entry : values.entrySet()) {
/* 794 */         output.put(createPath(section, entry.getKey(), this), entry.getValue());
/*     */       }
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public static String createPath(ConfigurationSection section, String key) {
/* 811 */     return createPath(section, key, (section == null) ? null : section.getRoot());
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public static String createPath(ConfigurationSection section, String key, ConfigurationSection relativeTo) {
/* 827 */     Validate.notNull(section, "Cannot create path without a section", new Object[0]);
/* 828 */     Configuration root = section.getRoot();
/* 829 */     if (root == null) {
/* 830 */       throw new IllegalStateException("Cannot create path without a root");
/*     */     }
/* 832 */     char separator = root.options().pathSeparator();
/*     */     
/* 834 */     StringBuilder builder = new StringBuilder();
/* 835 */     if (section != null) {
/* 836 */       for (ConfigurationSection parent = section; parent != null && parent != relativeTo; parent = parent.getParent()) {
/* 837 */         if (builder.length() > 0) {
/* 838 */           builder.insert(0, separator);
/*     */         }
/*     */         
/* 841 */         builder.insert(0, parent.getName());
/*     */       } 
/*     */     }
/*     */     
/* 845 */     if (key != null && key.length() > 0) {
/* 846 */       if (builder.length() > 0) {
/* 847 */         builder.append(separator);
/*     */       }
/*     */       
/* 850 */       builder.append(key);
/*     */     } 
/*     */     
/* 853 */     return builder.toString();
/*     */   }
/*     */ 
/*     */   
/*     */   public String toString() {
/* 858 */     Configuration root = getRoot();
/* 859 */     return 
/* 860 */       getClass().getSimpleName() + "[path='" + 
/*     */       
/* 862 */       getCurrentPath() + "', root='" + (
/* 863 */       (root == null) ? null : root
/* 864 */       .getClass().getSimpleName()) + "']";
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public static int toInt(Object object) {
/* 870 */     if (object instanceof Number) {
/* 871 */       return ((Number)object).intValue();
/*     */     }
/*     */     
/* 874 */     try { return Integer.valueOf(object.toString()).intValue(); }
/* 875 */     catch (NumberFormatException numberFormatException) {  }
/* 876 */     catch (NullPointerException nullPointerException) {}
/*     */     
/* 878 */     return 0;
/*     */   }
/*     */   
/*     */   public static double toDouble(Object object) {
/* 882 */     if (object instanceof Number) {
/* 883 */       return ((Number)object).doubleValue();
/*     */     }
/*     */     
/* 886 */     try { return Double.valueOf(object.toString()).doubleValue(); }
/* 887 */     catch (NumberFormatException numberFormatException) {  }
/* 888 */     catch (NullPointerException nullPointerException) {}
/*     */     
/* 890 */     return 0.0D;
/*     */   }
/*     */   
/*     */   public static long toLong(Object object) {
/* 894 */     if (object instanceof Number) {
/* 895 */       return ((Number)object).longValue();
/*     */     }
/*     */     
/* 898 */     try { return Long.valueOf(object.toString()).longValue(); }
/* 899 */     catch (NumberFormatException numberFormatException) {  }
/* 900 */     catch (NullPointerException nullPointerException) {}
/*     */     
/* 902 */     return 0L;
/*     */   }
/*     */ }


/* Location:              D:\fanbian\[D][龙之核心]DragonCore-2.6.0.3.jar!\org\yaml\snakeyamla\configuration\MemorySection.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */